import { createRouter, createWebHashHistory } from 'vue-router';

export default createRouter({
  history: createWebHashHistory(),
  routes: [
    {
      path: '/',
      redirect: { name: 'home' },
    },
    {
      path: '/login',
      name: 'login',
      component: () => import('@/views/login/index.vue'),
      meta: { title: '登录' },
    },
    {
      path: '/home',
      name: 'home',
      component: () => import('@/layout/index.vue'),
      redirect: { name: 'exam' },
      children: [
        {
          path: 'exam',
          name: 'exam',
          component: () => import('@/views/exam/index.vue'),
          meta: { title: '首页' },
        },
        {
          path: 'user',
          name: 'user',
          component: () => import('@/views/user/index.vue'),
          meta: { title: '个人中心' },
        },
        {
          path: 'statistical',
          name: 'statistical',
          component: () => import('@/views/statistical/index.vue'),
          meta: { title: '考试记录' },
        },
        {
          path: 'examlist',
          name: 'examlist',
          component: () => import('@/views/examList/index.vue'),
          meta: { title: '考试列表' },
        },
        {
          path: 'errorTopic',
          name: 'errorTopic',
          component: () => import('@/views/errorTopic/index.vue'),
          meta: { title: '错题集' },
        },
        {
          path: 'examresult',
          name: 'examresult',
          component: () => import('@/views/examResultList/index.vue'),
          meta: { title: '考试排行' },
        },
        {
          path: 'startExam',
          name: 'startExam',
          component: () => import('@/views/startExam/index.vue'),
          meta: { title: '开始考试' },
        },
        {
          path: 'examnotice',
          name: 'examnotice',
          component: () => import('@/views/examNotice/index.vue'),
          meta: { title: '考试通知' },
        },
      ],
    },
    {
      path: '/:pathMacth(.*)',
      name: '404',
      component: () => import('@/views/404/index.vue'),
    },
  ],
});
